package examenJunio2013DAM;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JTextField;
import javax.swing.JTextPane;

public class formulario extends JFrame {

	private JPanel contentPane;
	private JTextField decimal;
	private JTextField binario;
	private JTextField octal;
	private JTextField hexadecimal;
	private JButton btnLimpiar;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					formulario frame = new formulario();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public formulario() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 450, 300);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		JButton btnNewButton = new JButton("Convertir");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {

				binario.setText(Integer.toBinaryString((Integer.valueOf(decimal
						.getText()))));
				octal.setText(Integer.toOctalString((Integer.valueOf(decimal
						.getText()))));
				hexadecimal.setText(Integer.toHexString(((Integer
						.valueOf(decimal.getText())))));
			}
		});
		btnNewButton.setBounds(318, 22, 89, 23);
		contentPane.add(btnNewButton);

		JButton btnNewButton_1 = new JButton("Binario");
		btnNewButton_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				binario.setText(Integer.toBinaryString((Integer.valueOf(decimal
						.getText()))));
			}
		});
		btnNewButton_1.setBounds(318, 66, 89, 23);
		contentPane.add(btnNewButton_1);

		JButton btnNewButton_2 = new JButton("Octal");
		btnNewButton_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				octal.setText(Integer.toOctalString((Integer.valueOf(decimal
						.getText()))));
			}
		});
		btnNewButton_2.setBounds(318, 118, 89, 23);
		contentPane.add(btnNewButton_2);

		JButton btnNewButton_3 = new JButton("Hexadecimal");
		btnNewButton_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				hexadecimal.setText(Integer.toHexString(((Integer
						.valueOf(decimal.getText())))));
			}
		});
		btnNewButton_3.setBounds(318, 167, 89, 23);
		contentPane.add(btnNewButton_3);

		decimal = new JTextField();
		decimal.setBounds(25, 23, 124, 20);
		contentPane.add(decimal);
		decimal.setColumns(10);

		binario = new JTextField();
		binario.setBounds(115, 66, 124, 23);
		contentPane.add(binario);
		binario.setColumns(10);

		octal = new JTextField();
		octal.setBounds(116, 119, 123, 23);
		contentPane.add(octal);
		octal.setColumns(10);

		hexadecimal = new JTextField();
		hexadecimal.setBounds(115, 168, 124, 22);
		contentPane.add(hexadecimal);
		hexadecimal.setColumns(10);

		btnLimpiar = new JButton("Limpiar");
		btnLimpiar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				decimal.setText("");
				binario.setText("");
				octal.setText("");
				hexadecimal.setText("");
			}
		});
		btnLimpiar.setBounds(24, 214, 89, 23);
		contentPane.add(btnLimpiar);
	}
}
